package com.chj.design.sk;

//https://blog.csdn.net/rocketeerLi/article/details/81675073
public class Code16_Factory {
	public interface Clothes {
		public void introduce();

		public void getPlace();
	}

	public static abstract class Shirt implements Clothes {
		@Override
		public void introduce() {
			System.out.println("我是衬衫!!! ");
		}
	}

	public static abstract class Outerwear implements Clothes {
		@Override
		public void introduce() {
			System.out.println("我是外衣!!! ");
		}
	}

	public static abstract class Pants implements Clothes {
		@Override
		public void introduce() {
			System.out.println("我是裤子!!! ");
		}
	}

	public static class ChineseShirt extends Shirt {
		public void getPlace() {
			System.out.println("产自中国!!! ");
		}
	}

	public static class AmericanShirt extends Shirt {
		public void getPlace() {
			System.out.println("产自美国!!! ");
		}
	}

	public static class ChineseOuterwear extends Outerwear {
		public void getPlace() {
			System.out.println("产自中国!!! ");
		}
	}

	public static class AmericanOuterwear extends Outerwear {
		public void getPlace() {
			System.out.println("产自美国!!! ");
		}
	}

	public static class ChinesePants extends Pants {
		public void getPlace() {
			System.out.println("产自中国!!! ");
		}
	}

	public static class AmericanPants extends Pants {
		public void getPlace() {
			System.out.println("产自美国!!! ");
		}
	}

	public interface ClothesProducer {
		// 生产一件衬衫。
		public Clothes produceShirt();

		// 生产一件外套。
		public Clothes produceOuterwear();

		// 生产一条裤子。
		public Clothes producePants();
	}

	public static class ChineseFactory implements ClothesProducer {
		@Override
		public Clothes produceShirt() {
			return new ChineseShirt();
		}

		@Override
		public Clothes produceOuterwear() {
			return new ChineseOuterwear();
		}

		@Override
		public Clothes producePants() {
			return new ChinesePants();
		}
	}

	public static class AmericanFactory implements ClothesProducer {
		@Override
		public Clothes produceShirt() {
			return new AmericanShirt();
		}

		@Override
		public Clothes produceOuterwear() {
			return new AmericanOuterwear();
		}

		@Override
		public Clothes producePants() {
			return new AmericanPants();
		}
	}

	public static void main(String[] args) {
//		/中国工厂。
		ClothesProducer factoryChinese = new ChineseFactory();
		// 美国工厂。
		ClothesProducer factortAmerican = new AmericanFactory();

		System.out.println("生产一条中国裤子-------------");
		Clothes pants_China = factoryChinese.producePants();
		pants_China.introduce();
		pants_China.getPlace();

		System.out.println("生产一件美国衬衫-------------");
		Clothes shirt_America = factortAmerican.produceShirt();
		shirt_America.introduce();
		shirt_America.getPlace();
	}
}
